<%--
 *  File:    ForumMain.jsp
 *  @Author: Kent Zhong
 *  Date:    2002/04/23
 *
 *  Copyright (C) 2000 - 2001 Oval Technologies, Inc.
 *  All rights reserved.
 *
 *  This software is the confidential and proprietary information of Oval
 *  Technologies, Inc. ("Confidential Information").  You shall not
 *  disclose such Confidential Information and shall use it only in
 *  accordance with the terms of the license agreement you entered into
 *  with Oval.
--%>


<%@ include file="/inc/SessionTimeout.inc"%>
<%@ page language="java" %>
<%@ page import="java.util.*" %>
<%@ page import="org.apache.log4j.Category" %>

<%@ page contentType = "text/html;charset=UTF-8" %>
<%@ taglib uri="/WEB-INF/PageFlow.tld" prefix="PageFlow" %>
<%@ taglib uri="/WEB-INF/struts-logic.tld" prefix="logic" %>
<%@ taglib uri="/WEB-INF/oval-tag.tld" prefix="oval" %>
<%@ taglib uri="/WEB-INF/custom.tld" prefix="custom" %>


<% //--------------------------------------  setting logger --%>
<%
  	Category cat = Category.getInstance("jsp.ForumMain");
%>

<% //--------------------------------------  variant and initialization --%>
<%
	String strModuleName = "BIEE";
  	String strTableName = "ovforum";
	String privilegeCode = "Z0401";

  	//get current userinfo
  	HashMap CurUserInfo = (HashMap)session.getAttribute("userinfo");
  	cat.debug("The userinfo is :"+CurUserInfo);
  	cat.info("enter my page");

    String forumid=new String("");
    if(request.getParameter("forumid")!=null)
    {
       forumid=(String) request.getParameter("forumid");
    }
%>

<% //--------------------------------------  include files list --%>
<%@ include file="/inc/Security.inc" %>
<%@ include file="/inc/FrmDefault.inc" %>
<%@ include file="/inc/PageDefault.inc" %>
<%@ include file="/inc/LocationDefault.inc" %>

<html>
<head>
<title>ForumEdit</title>
<PageFlow:CheckPageFlow pageName="p_forummain"/>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<link rel="stylesheet" href="../css/<%= strLanguageCode %>/main.css" type="text/css">
<script language="JavaScript" src="../css/<%= strLanguageCode %>/script.js"></script>
<script language="JavaScript" src="../js/FuncLib.js"></script>
<script language="JavaScript" src="../js/Calendar.js"></script>
<script language="JavaScript" src="../js/ScriptLib.js"></script>

<script language="JavaScript" >


    function page_orgselect()
    {
        window.open("CompanyMultiSelectPop.jsp?<%= OvalTools.randomURL() %>", "pop1", "height=200, width=600,top=100,left=100,toolbar=no, menubar=no, scrollbars=yes, resizable=no, location=no, status=no");
    }

    function checkDate(_date0, _date, message)
    {
       var frm = document.forumeditform;
       var date0 = eval("document.forumeditform." + _date0);
       var date = eval("document.forumeditform." + _date);
       date.value = dateCheck(date0.value, 'yyyy-MM-dd', '<%=JspHelper.filterNull( session.getAttribute("dateformat") )%>');
       if ( date.value < 0 )
       {
           alert(message);
           date0.focus();
       }
    }

    function Empty_check(checkobj,strMessage)
    {
        var obj = eval("document.forumeditform." + checkobj);
        if(isEmpty(obj.value))
        {
            alert(strMessage);
            obj.focus();
        }
    }

    function page_save()
    {
      //alert("2");
        var blSave=true;
        if ( isEmpty(document.forumeditform.expiredate.value) )
        {
           alert('<%= message.getMessageDesc("VALUE_NOT_NULL", label.getLabelName("L_DueDate1",false)) %>');
           blSave= false;
           return;
        }
        if ( ! isEmpty(document.forumeditform.expiredate.value)  && ! isEmpty(document.forumeditform.createdate.value) &&
        (document.forumeditform.createdate.value > document.forumeditform.expiredate.value) )
        {
           alert('<%= message.getMessageDesc("CAN_NOT_LATE_THAN", label.getLabelName("L_EntryDate",false), label.getLabelName("L_DueDate1",false)) %>');
           blSave= false;
           return;
        }
       //if ( isEmpty(document.forumeditform.forumcode.value)&&  !document.forumeditform.forumcode.disabled)
        //{
          // alert('<%= message.getMessageDesc("VALUE_NOT_NULL", label.getLabelName("L_InfoCode",false)) %>');
          // blSave= false;
          // return;
      //  }

        if ( isEmpty(document.forumeditform.forumtype.value) )
        {
           alert('<%= message.getMessageDesc("VALUE_NOT_NULL", label.getLabelName("L_InfoType",false)) %>');
           blSave= false;
           return;
        }
        if ( isEmpty(document.forumeditform.frmt0.value) )
        {
           alert('<%= message.getMessageDesc("VALUE_NOT_NULL", label.getLabelName("L_Title",false)) %>');
           blSave= false;
           return;
        }
        if ( isEmpty(document.forumeditform.frmd0.value) )
        {
           alert('<%= message.getMessageDesc("VALUE_NOT_NULL", label.getLabelName("L_Content",false)) %>');
           blSave= false;
           return;
        }

        if(!checkNull(document.forumeditform))return;


        if(blSave)
        {
             //alert("1");

            MLCSTransform(document.forumeditform);

            document.forumeditform.actionname.value = "done";
            document.forumeditform.target = "_parent";
            isRunning = true;
            document.forumeditform.submit();
        }
        else
            return;
    }
    function setParent(strorglist)
    {
        if ( isEmpty(document.forumeditform.toorglist.value) )
            document.forumeditform.toorglist.value=strorglist;
        else
            document.forumeditform.toorglist.value+=","+strorglist;
        var remote = window.open("","pop1");
        if (remote != null)
            remote.close();
    }

var popwindow;
function page_mulilang(name,label,num,need)
{
  var forumid=document.forumeditform.forumid.value;
  if(popwindow!=null)
    popwindow.close();
  var strurl="../common/Lang.jsp?<%= OvalTools.randomURL() %>&form=forumeditform&module=BIEE&mlctype="+label+"&nativelanguage="+need+"&schema=ovforumlang&entityid="+forumid+"&entitytype="+name+"&contentid=forumlangid&colindex="+num;
  var strStatus= "height=250, width=250,top=100,left=100,toolbar=n0, menubar=no, scrollbars=no, resizable=no, location=no, status=no";
  popwindow=window.open(strurl, "newwindow",strStatus);
}
<%--[SCRIPT]    [SCRIPT]--%>
</script>
</head>
<body leftmargin="0" topmargin="0" marginwidth="0" marginheight="0">
<form name="forumeditform" method="post" action="../Dispatcher"  target="_parent">
    <input type="hidden" name="pagename" value="p_forummain">
    <input type="hidden" name="actionname">
    <input type="hidden" name="languagecode" value="<%= strLanguageCode %>">
<%--    <input type="hidden" name=forumid>--%>

<%
    Vector alltype=(Vector)pageContext.getAttribute("alltype");
    if(alltype==null)
    {
        alltype=new Vector();
    }

     HashMap foruminfo=(HashMap)pageContext.getAttribute("foruminfo");
    if(foruminfo==null)
    {
        foruminfo=new HashMap();
    }

    Integer IntForumType=(Integer)foruminfo.get("forumtype");
    if(IntForumType==null)
    {
        IntForumType=new Integer(-1);
    }
    int forumtype=IntForumType.intValue();

%>
  <input type="hidden" name="numrows" value="2">

  <input type="hidden" name="orgid" value="<%=JspHelper.filterNull(CurUserInfo.get("orgid"))%>">
  <input type="hidden" name="status" value="10">
  <input type="hidden" name="maker" value="<%=JspHelper.filterNull(CurUserInfo.get("userid"))%>">

<table width="100%" cellspacing="0" cellpadding="0">
  <%--form name="form1" method="post" action="../ordermanagement/oe/NewSalesOrderMain.htm"--%>
    <tr>
      <td valign="top">
        <table border="1" cellspacing="0" bordercolorlight="#999999" bordercolordark="#FFFFFF" align="center" width="100%" cellpadding="1">
         <tr>
            <td colspan="4" class="deepblue-left" height="22"> <img src="../images/<%= strLanguageCode %>/quote.gif">
              &nbsp;<%=label.getLabelName("L_BasicInfo")+label.getLabelName("L_Colon")%> </td>
          </tr>
         <%
                boolean isAuto = (pageContext.getAttribute("isauto") != null && pageContext.getAttribute("isauto").toString().equalsIgnoreCase("Y"))?true:false;
                String codeClass = isAuto?"td-text":"need";
                String codeDisabled = isAuto?"disabled":"";

         %>
          <tr>
            <td  class="<%=JspHelper.filterNull(codeClass)%>">&nbsp;<%=label.getLabelName("L_InfoCode")+label.getLabelName("L_Colon")%></td>
            <td width="266">
            <%if(forumid!=null){%>
            &nbsp;<input type="text" name="forumcode" style="border:0" disabled size="20" value='<oval:write name="foruminfo" property="forumcode"/>' onchange="javascript:Empty_check('forumcode','<%= message.getMessageDesc("VALUE_NOT_NULL", label.getLabelName("L_InfoCode",false)) %>');">
            <%} else {%>
              &nbsp;<input type="text" name="forumcode" size="20" value='' <%=JspHelper.filterNull(codeDisabled)%> onchange="javascript:Empty_check('forumcode','<%= message.getMessageDesc("VALUE_NOT_NULL", label.getLabelName("L_InfoCode",false)) %>');">
              <%}%>
            </td>
            <td class="need"  >&nbsp;<%=label.getLabelName("L_InfoType")+label.getLabelName("L_Colon")%></td>
            <td width="277">
              &nbsp;<select name="forumtype" onchange="javascript:Empty_check('forumtype','<%= message.getMessageDesc("VALUE_NOT_NULL", label.getLabelName("L_InfoType",false)) %>');">
                <option value="">------------</option>
                <logic:iterate id="alltypeitem" collection="<%= alltype %>">
                 <%
                        HashMap hmTemp=(HashMap)pageContext.getAttribute("alltypeitem");
                        if(hmTemp==null)
                        {
                            hmTemp=new HashMap();
                        }
                        Integer oForumType=(Integer)hmTemp.get("value");
                        if(oForumType==null)
                        {
                            oForumType=new Integer(-1);
                        }
                        int nForumType=oForumType.intValue();
                        String strSelected="";
                        if(nForumType==forumtype)
                            strSelected="Selected";
                    %>
                    <%if(forumid!=null){%>
                    <option value='<oval:write name="alltypeitem" property="value"/>' <%=JspHelper.filterNull(strSelected)%>><oval:write name="alltypeitem" property="valuename"/></option>
                     <%} else {%>
                    <option value='<oval:write name="alltypeitem" property="value"/>' ><oval:write name="alltypeitem" property="valuename"/></option>
                      <%}%>
                </logic:iterate>
              </select>
            </td>
          </tr>
        	<%
          		String strTextTypeCN = "td-text";
          		String strTextTypeEN = "td-text";
          		String strNullCN = "Y";
          		String strNullEN = "Y";
          		if(strLanguageCode.equalsIgnoreCase("cn"))
          		{
            		strTextTypeCN = "need";
            		strNullCN = "N";
            	}
          		if(strLanguageCode.equalsIgnoreCase("en"))
          		{
            		strTextTypeEN = "need";
            		strNullEN = "N";
            	}

        	%>

          <tr>
            <td class="<%=JspHelper.filterNull( strTextTypeCN )%>">&nbsp;<%=label.getLabelName("L_Title")+label.getLabelName("L_Colon")%></td>
            <td colspan="3">

              &nbsp;<custom:text name="foruminfo" property="forumtitle" size="42"  module="BIEE" label="L_Title" needMLC="true"  isFirstMLC="true" multiLangType="frmt" entityId="forumid" contentId="forumlangid" colIndex="0"/>
              <a onclick="page_mulilang('frmt','L_Title',0,'');"><custom:button type="3" label="L_Ln" imgsrc="ln.gif" border="0"/></a>
            </td>
          </tr>
          <tr>
            <td class="<%=JspHelper.filterNull( strTextTypeCN )%>">&nbsp;<%=label.getLabelName("L_Content")+label.getLabelName("L_Colon")%></td>
            <td colspan="3">
              &nbsp;<custom:textarea name="foruminfo" property="forumdescription" cols="88" rows="6" module="BIEE" label="L_Content" needMLC="true"  multiLangType="frmd" entityId="forumid" contentId="forumlangid" colIndex="0"/>

            </td>
          </tr>

          <tr>
            <td class="td-text">&nbsp;<%=label.getLabelName("L_EntryDate")+label.getLabelName("L_Colon")%></td>
            <td>&nbsp;<%= OvalTools.getDate((String)session.getAttribute("dateformat")) %><%--today's date--%></td>
            <input name=createdate type=hidden value='<%= OvalTools.getDate("yyyy-MM-dd") %>'>
            <td class="need" >&nbsp;<%=label.getLabelName("L_DueDate1")+label.getLabelName("L_Colon")%></td>
            <%
                java.util.Calendar endCalendar=java.util.Calendar.getInstance();
                endCalendar.setTime(new java.util.Date());
                endCalendar.add(java.util.Calendar.DATE,7);
                java.util.Date endDate=endCalendar.getTime();

            %>
            <td>
              &nbsp;<input type="text" name="expiredatefomat" size="20" value='<%= OvalTools.dateToString(endDate,(String)session.getAttribute("dateformat")) %>'
               onblur="checkDate( 'expiredatefomat','expiredate', '<%= message.getMessageDesc("VALUE_MUST_BE_DATE", label.getLabelName("L_DueDate1",false)) %>')">
               <input type="hidden" name="expiredate" value='<%= OvalTools.dateToString(endDate,"yyyy-MM-dd") %>' />
              <a onclick="javascript:c.show(this,'forumeditform.expiredatefomat','<%=JspHelper.filterNull( session.getAttribute("dateformat") )%>');"><custom:button type="3" label="L_Asterisk" imgsrc="Time.gif" border="0"/></a>
            </td>
          </tr>
        </table>
      </td>
    </tr>

          <tr>
        <td style="display:none">
            <custom:hidden name="foruminfo" property="forumid"/>
        </td>
      </tr>

    <tr>
      <td class="summary_top"></td>
    </tr>
    <tr>
      <td class="td_center">
      <a onclick="page_save();"><custom:button type="1" label="L_Finish" imgsrc="finish.gif" border="0" style="width:60"/></a>
      <a onclick="history.go(-1);"><custom:button type="1" label="L_Cancel" imgsrc="cancel.gif" border="0" style="width:60"/></a></td>
    </tr>

</table>
</form>
</body>
</html>


